package com.whxd.smarthome.core.repository;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import com.whxd.smarthome.core.entity.DhDevice;
public interface DhDeviceDao extends JpaRepository<DhDevice, Long> {
	@Query("from DhDevice where deviceId = ?1 ")
	DhDevice findByDeviceId(String deviceId);
	
	@Modifying
	@Query("update DhDevice d set d.deviceName = ?2 where d.deviceId = ?1")
	void updateByDeviceId(String deviceId, String deviceName);
	
	@Modifying
	@Query("update DhDevice d set d.beSharedTo = ?2 where d.deviceId = ?1")
	void updateDeviceShareStatus(String deviceId, boolean shareStatus);
	
	@Modifying
	@Query("delete from DhDevice d where d.deviceId = ?1")
	void deleteDevice(String deviceId);
}
